package com.thread.demo.service.impl;

import com.thread.demo.service.AsyncService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class AsyncServiceImpl implements AsyncService {
    private static final Log log = LogFactory.getLog(AsyncServiceImpl.class);

    @Override
    @Async
    public void executeAsync() {
        log.info("异步方法开始");
        log.info("当前线程名字：" + Thread.currentThread().getName());
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        log.info("异步方法结束");
    }
}
